<template>
  <div>
    <el-container>
      <el-aside style="overflow: hidden; min-height: 100vh; background-color: white; width: 250px">
        <el-menu :default-active="$route.path" router background-color="#fff" text-color="#000" active-text-color="#ffd04b">
          <el-menu-item index="/allInvitationRecords">
            <span slot="title">邀请记录</span>
          </el-menu-item>
          <el-menu-item index="/allInvitedRecords">
            <span slot="title">被邀请记录</span>
          </el-menu-item>
          <el-menu-item index="/chat">
            <span slot="title">聊天</span>
          </el-menu-item>
          <el-menu-item index="/orderRecords">
            <span slot="title">商家</span>
          </el-menu-item>
        </el-menu>
      </el-aside>
      <el-divider direction="vertical"></el-divider>
      <el-main>
        <router-view/>
      </el-main>
    </el-container>
  </div>
</template>

<script>
export default {
  name: "Layout",

  data () {
    return {
      user: sessionStorage.getItem("user") ? JSON.parse(sessionStorage.getItem("user")) : {},
      adminVisible: true,
      recordsCount: 10
    }
  },
  mounted() {
    this.checkUserType();
  },
  methods:{
    logout() {
      sessionStorage.removeItem("user");
      localStorage.removeItem("menus");
      this.$router.push("/login");
    },
    checkUserType() {
      // 检查userType是否为0
      this.adminVisible = this.user.userType === 0;
    }
  }
}
</script>

<style>
.el-menu{
  border-right: none !important;
}
</style>
